from quart import Quart
import logging

from src.basedata.interfaces.facade.api.routes.health_check_route.health_check import health_check_bp
from src.basedata.interfaces.facade.api.routes.root_route import api_bp

app = Quart(__name__)

# 注册健康检查蓝图到应用
app.register_blueprint(health_check_bp)
# 注册api蓝图到应用
app.register_blueprint(api_bp)


logger = logging.getLogger(__name__)


def init_web(loop, api):
    host = api.get("host", "0.0.0.0")
    port = int(api.get("port", 8080))
    logger.info(f"init web server, host:{host}, port:{port}")
    return app.run(loop=loop, port=port, host=host)
